package com.example.hikvison.test2;


import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;


/**
 * Auto Create on 2021-08-18 11:23:08
 */
public class ArtemisPostTest_2 {
    /**
     * 请根据自己的appKey和appSecret更换static静态块中的三个参数。
     */
    static {
        ArtemisConfig.host ="117.78.22.22:443"; //artemis 网关服务器 ip 端口
        ArtemisConfig.appKey ="27779269"; //秘钥 appkey
        ArtemisConfig.appSecret ="zOEXl73czsWZQ1Odadh2";//秘钥 appSecret
    }
    /**
     * 能力开放平台的网站路径
     * 路径不用修改，就是/artemis
     */
    private static final String ARTEMIS_PATH = "/artemis";

    //获取监控点预览取流URL
    public static String previewURLs(PreviewURLsRequest previewURLsRequest ){
        String previewURLsDataApi = ARTEMIS_PATH +"/api/video/v1/cameras/previewURLs";
        Map<String,String> path = new HashMap<String,String>(2){
            {
                put("https://",previewURLsDataApi);
            }
        };
        String body=JSON.toJSONString(previewURLsRequest);
        String result =ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
        return result;
    }

    public static void main(String[] args) {
        PreviewURLsRequest request = new PreviewURLsRequest();
        request.setCameraIndexCode("9f012806aa814fd1bdcc7b475331f764");
        request.setStreamType(1);
        request.setProtocol("hls");
        request.setTransmode(1);
        request.setExpand("streamform=rtp");
        String str = previewURLs(request);
        System.out.println(str);

    }
}

